n='4'
num_list='5 0 3 1'

n=int(n)
num_list=list(map(int,num_list.split()))

def buble_sort(li):
    for i in range(len(li)-1):
        exchange=False
        for j in range(len(li)-i-1):
            if li[j+1]<li[j]:
                li[j],li[j+1]=li[j+1],li[j]
                exchange=True
        if exchange==False:
            break

new_mex_list=[]
for ind in range(n):
    data_list=num_list.copy()
    data_list.pop(ind)
    buble_sort(data_list)
    if data_list[0]!=0:
        new_mex_list.append(data_list[0]-1)
    else:
        for i in range(len(data_list)):
            if data_list[i+1]-data_list[i]!=1:
                new_mex_list.append(data_list[i]+1)
                break

print(' '.join(map(str,new_mex_list)))





